package org.mybatis.mapper;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.mapper.interfaces.GenericMapper;
import org.springframework.beans.factory.support.GenericBeanDefinition;

public class MybatisMappers{
	private static final List<GenericBeanDefinition> mappers = new ArrayList<>();
	private static final List<GenericBeanDefinition> genericMappers = new ArrayList<>();
	
	public static void add(GenericBeanDefinition definition){
		mappers.add(definition);
		String className = definition.getBeanClassName();
	    Class<?> clazz = null;
		try {
			clazz = Class.forName(className);
		} catch (ClassNotFoundException e) {
		}
		
		if(GenericMapper.class.isAssignableFrom(clazz)){
			genericMappers.add(definition);
		}
	}
	
	public static List<GenericBeanDefinition> getGenericmappers() {
		return genericMappers;
	}

	public static List<GenericBeanDefinition> getMappers() {
		return mappers;
	}
}
